|
|
|
|
<AuthToken>.RefreshToken (Función) Actualiza el token OAuth2 de un usuario cuando caduca. Novedad versión 2024 // OAuth session SessionToken is AuthToken // OAuth session bufToken is Buffer sAuthPersistenceFile is string = fDataDir() + [fSep] + "AuthSession.bin" // OAuth connection parameters m_Svc is OAuth2Parameters // OAuth Service (Login) m_Svc.ClientID = "my_client_id" m_Svc.ClientSecret = "123456-my_client_secret-387854" m_Svc.AuthURL = "https://api.server.com/connect/authorize" m_Svc.TokenURL = "https://api.server.com/connect/token" m_Svc.Scope = "openid profile offline_access" m_Svc.RedirectionURL = "http://localhost:3333" // or // m_Svc IS OpenIDParameters // Service OAuth (Login) // m_Svc.ClientID = "my_client_id" // m_Svc.ClientSecret = "123456-my_client_secret-387854" // m_Svc.ConfigurationURL = "https://api.server.com/.well-known/openid-configuration" // m_Svc.RedirectionURL = "http://localhost:3333" // Token previously stored? IF fFileExist(sAuthPersistenceFile) THEN WHEN EXCEPTION IN // Loads the session bufToken = fLoadBuffer(sAuthPersistenceFile) Deserialize(SessionToken, bufToken, psdBinary) DO // Unable to read token again ToastDisplay("Invalid stored session") ELSE // Token has expired or will expire in the next minute // and it is renewable? IF (SessionToken.ExpirationDate-1min < SysDateTime()) _AND_ SessionToken.Refresh <> "" THEN SessionToken = SessionToken.RefreshToken() IF SessionToken.Valid THEN Serialize(SessionToken, bufToken, psdBinary) fSaveBuffer(sAuthPersistenceFile, bufToken) ELSE Error("Unable to refresh session") END END END END IF NOT SessionToken.Valid THEN // Connect to the service SessionToken = AuthIdentify(m_Svc) IF SessionToken.Valid THEN // Save token Serialize(SessionToken, bufToken, psdBinary) fSaveBuffer(sAuthPersistenceFile, bufToken) END END IF NOT SessionToken.Valid THEN Error("Unable to open the session", ErrorInfo()) ELSE MyIdentity is OpenIDIdentity = OpenIDReadIdentity(SessionToken) IF MyIdentity.Valid THEN // The information that can be retrieved about the identity of the connected user // depend on the site that used for the authentication Info("Connection successful: " + MyIdentity.Source) ELSE Info("Valid connection, but invalid identity ", InfoError()) END END
Sintaxis
<Result> = <Token>.RefreshToken()
<Result>: Variable de tipo AuthToken Variable de tipo AuthToken que corresponde al token actualizado. <Token>: Variable de tipo AuthToken Nombre de la variable de tipo AuthToken que corresponde al token que debe actualizarse. Puede obtener este token utilizando la función AuthIdentify, por ejemplo. Observaciones Algunos tokens no pueden actualizarse. La propiedad Refresh de la variable de tipo AuthToken permite determinar si se puede actualizar el token.
Esta página también está disponible para…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|